import java.util.Scanner;

public class Main {
    public static boolean zidian(String[] ch) {
        for (int i = 0; i < ch.length - 1; i++) {
            if (ch[i].compareTo(ch[i + 1]) > 0) {
                return false;
            }
        }
        return true;
    }
    public static boolean len(String[] ch) {
        for (int i = 0; i < ch.length - 1; i++) {
            if (ch[i].length() > ch[i + 1].length()) {
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] ch = new String[n];
        for (int i = 0; i < n; i++) {
            ch[i] = in.next();
        }
        boolean s1 = zidian(ch);
        boolean s2 = len(ch);
        if (s1 && s2) {
            System.out.println("both");
        } else if (s1) {
            System.out.println("lexicographically");
        } else if (s2) {
            System.out.println("lengths");
        } else {
            System.out.println("none");
        }
    }
}
